package code.part04_collection;

import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Collection;

/**
 * @author: ZJT
 * @Time: 2021/7/14
 * @Description: 集合框架
 */
public class P01_Collection {

    @Test
    public void collectionCommon() {

        Collection c1 = new ArrayList();
        c1.add(1);
        int size = c1.size();

        ((ArrayList) c1).add(0, "a");

        Collection c2 = new ArrayList();
        c2.add("b");
        c1.addAll(c2);

        System.out.println(c1.contains("a"));
        System.out.println(c1.containsAll(c2));
        System.out.println(c1.isEmpty());

        c2.add("d");
        //从指定集合中保留包含参数集合的元素,其他元素则删除
        boolean retainAllFlag = c2.retainAll(c1);
        c1.retainAll(c2);

        Object[] objects = c1.toArray();

        c1.remove("a");
        c1.clear();
    }
}
